//
//  NSUserDefaultsHelper.m
//  SmartLife
//
//  Created by Lawrence on 15/11/6.
//  Copyright © 2015年 Lawrence. All rights reserved.
//

#import "NSUserDefaultsHelper.h"

@implementation NSUserDefaultsHelper

-(instancetype)init{
    if (self=[super init]) {
        
    }
    return self;
}

#pragma mark 写入数据
+(void)writeDataforUserDefaults:(NSUserDefaults *) users andData:(NSDictionary *)data{
    
    if (data!=nil&&users!=nil) {
        
        NSArray *dictKeys=[data allKeys];
        
        for (int i=0;i<data.count;i++) {
            NSString *userData=[data objectForKey:dictKeys[i]];
            [users setObject:userData forKey:dictKeys[i]];
        }
    }
}

#pragma mark 读取数据
+(NSMutableArray *)readerDataforUserDefaults:(NSUserDefaults *) users forKey:(NSArray *)keys{
    
    NSMutableArray *dict=nil;
    
    if (users!=nil) {
        
        dict=[[NSMutableArray alloc] init];
        
        for (NSString *key in keys) {
            
            NSString *userData=[users valueForKey:key];
            if (userData!=nil) {
                [dict addObject:userData];
            }
           // [dict addObject:userData];
        }
        
        return dict;
    }
    return nil;
}
@end
